<{assign var=page_title value='管理角色'}>
<{include file="FASHION/page_header.phtml"}>

<ul id="sortable">
<{if $list}><{foreach item=r from=$list}>
<li class="ui-state-default" role_id="<{$r.id}>">
	<span class="state-title" id="title_<{$r.id}>" title="<{$r.name}>"><{$r.name|truncate:44:"..."}></span>
	<span class="state-menu">
		<a href="<{url a="role-modify" id=$r.id}>" class="priv" title="设置权限"></a>
		<a href="javascript:;" onclick="del('<{$r.id}>')" class="remove" title="删除"></a>
	</span>
</li>
<{/foreach}><{/if}>
</ul>

<input type="button" value="新建" onclick="g2('<{url a='role-add'}>')" />
<input type="button" value="排序" onclick="save_ordered()" />

<div id="dialog" title="新建用户角色" style="display:none;">
	<form action="<{url a='role-save'}>" method="post" id="form1">
		角色名：<input type="text" name="title" id="title" class="text ui-widget-content ui-corner-all" value="" />
		<input type="hidden" name="role_id" id="role_id" value="" />
	</form>
</div>

<script>
$("#sortable").sortable();
$("#sortable").disableSelection();

function del(role_id)
{
	if(confirm('确认删除?'))
	{
		$.get('<{$root}>/role-delete/role_id/'+role_id, function(jsn){
			if(jsn.level=='notice') {
				$("#sortable li[role_id="+role_id+"]").remove();
			}
			alert(jsn.message);
		});
	}
}

function save_ordered()
{
	var ary	=	new Array();
	$("#sortable li").each(function(){
		ary.push($(this).attr('role_id'));
	})
	$.get('<{$root}>/role-sort/s/'+ary.toString(),function(jsn){
		alert(jsn.message);
	});
}
</script>

<{include file="FASHION/page_footer.phtml"}>
